package top.laoshuzi.server.userservice.service.impl;

import org.apache.thrift.TException;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import top.laoshuzi.server.userservice.dataobject.UserInfo;
import top.laoshuzi.server.userservice.bo.UserInfoBO;
import top.laoshuzi.server.userservice.dao.UserAccountRepository;
import top.laoshuzi.server.userservice.dao.UserInfoRepository;
import top.laoshuzi.server.userservice.service.UserService;

@Service
public class UserServiceImpl implements UserService.Iface {

    @Autowired
    private UserAccountRepository userAccountRepository;
    @Autowired
    private UserInfoRepository userInfoRepository;

    @Override
    public UserInfoBO updateUserInfo(long id, UserInfoBO userInfoBO) throws TException {

        UserInfo userInfo = new UserInfo();
        userInfo.setId(id);
        BeanUtils.copyProperties(userInfoBO, userInfo);

        UserInfo save = userInfoRepository.save(userInfo);

        UserInfoBO bo = new UserInfoBO();
        BeanUtils.copyProperties(save, bo);
        return bo;
    }
}
